package com.ruoyi.model.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.model.domain.ModelPreprocessing;
import com.ruoyi.model.service.IModelPreprocessingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型关联的预处理过程信息，存储预处理步骤、参数及过程数据Controller
 * 
 * @author weihanqiang
 * @date 2025-08-03
 */
@RestController
@RequestMapping("/model/preprocessing")
public class ModelPreprocessingController extends BaseController
{
    @Autowired
    private IModelPreprocessingService modelPreprocessingService;

    /**
     * 查询模型关联的预处理过程信息，存储预处理步骤、参数及过程数据列表
     */
    @PreAuthorize("@ss.hasPermi('model:preprocessing:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelPreprocessing modelPreprocessing)
    {
        startPage();
        List<ModelPreprocessing> list = modelPreprocessingService.selectModelPreprocessingList(modelPreprocessing);
        return getDataTable(list);
    }

    /**
     * 导出模型关联的预处理过程信息，存储预处理步骤、参数及过程数据列表
     */
    @PreAuthorize("@ss.hasPermi('model:preprocessing:export')")
    @Log(title = "模型关联的预处理过程信息，存储预处理步骤、参数及过程数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelPreprocessing modelPreprocessing)
    {
        List<ModelPreprocessing> list = modelPreprocessingService.selectModelPreprocessingList(modelPreprocessing);
        ExcelUtil<ModelPreprocessing> util = new ExcelUtil<ModelPreprocessing>(ModelPreprocessing.class);
        util.exportExcel(response, list, "模型关联的预处理过程信息，存储预处理步骤、参数及过程数据数据");
    }

    /**
     * 获取模型关联的预处理过程信息，存储预处理步骤、参数及过程数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:preprocessing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(modelPreprocessingService.selectModelPreprocessingById(id));
    }

    /**
     * 新增模型关联的预处理过程信息，存储预处理步骤、参数及过程数据
     */
    @PreAuthorize("@ss.hasPermi('model:preprocessing:add')")
    @Log(title = "模型关联的预处理过程信息，存储预处理步骤、参数及过程数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelPreprocessing modelPreprocessing)
    {
        modelPreprocessing.setCreator(getUsername());
        modelPreprocessing.setCreatorId(getUserId());
        return toAjax(modelPreprocessingService.insertModelPreprocessing(modelPreprocessing));
    }

    /**
     * 修改模型关联的预处理过程信息，存储预处理步骤、参数及过程数据
     */
    @PreAuthorize("@ss.hasPermi('model:preprocessing:edit')")
    @Log(title = "模型关联的预处理过程信息，存储预处理步骤、参数及过程数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelPreprocessing modelPreprocessing)
    {
        return toAjax(modelPreprocessingService.updateModelPreprocessing(modelPreprocessing));
    }

    /**
     * 删除模型关联的预处理过程信息，存储预处理步骤、参数及过程数据
     */
    @PreAuthorize("@ss.hasPermi('model:preprocessing:remove')")
    @Log(title = "模型关联的预处理过程信息，存储预处理步骤、参数及过程数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(modelPreprocessingService.deleteModelPreprocessingByIds(ids));
    }
}
